package com.iweb.lesson08;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

/**
 * 作者: jack
 * 时间: 2020-07-11 09:48
 * 描述: Test
 */
public class Test {

    // 捕获
    public void readFile() {
        // 读取文件
        // 创建文件流对象
        try {
            FileReader in = new FileReader("C:\\Users\\jack\\Desktop\\java06\\code\\word.txt");
            BufferedReader reader = new BufferedReader(in);
            System.out.println(reader.readLine());
            System.out.println(reader.readLine());
        } catch (FileNotFoundException e) {
            // 打印异常跟踪的栈的信息
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void _readFile() throws FileNotFoundException, IOException {
        // 读取文件
        // 创建文件流对象
        FileReader in = new FileReader("C:\\Users\\jack\\Desktop\\java06\\code\\word.txt");
        BufferedReader reader = new BufferedReader(in);
        System.out.println(reader.readLine());
        System.out.println(reader.readLine());
    }

    public static void main(String[] args) {
        Test test = new Test();
        test.readFile();

        try {
            test._readFile();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
